package org.xjst.utils
{
{
	import mx.core.Container;
	import mx.core.UIComponent;

/**
 * Provides general UI related utilities.
 */
public class UIUtils
{
	/**
	 * Shows or hides the UI without removing from the parent.
	 */
	public static function showUI(ui:UIComponent, show:Boolean):void {
		ui.visible = show;
		ui.explicitWidth = show ? undefined : 0;
		ui.explicitHeight = show ? undefined : 0;
	}

	/**
	 * Removes the given child from the specified parent if the child is on the parent.
	 * @return true if the child is removed from the parent; false if the child was not on the parent in the first place.
	 */
	public static function removeChildIfContains(child:UIComponent, parent:Container):Boolean {
		if(parent.contains(child)) {
			parent.removeChild(child);
			return true;
		}
		return false;
	}

} // End class
} // End package